package cn.wolfcode.wolf2w.search.service.impl;

import cn.wolfcode.wolf2w.search.domain.UserInfoEs;
import cn.wolfcode.wolf2w.search.repository.UserInfoEsRepository;
import cn.wolfcode.wolf2w.search.service.IUserInfoEsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserInfoEsServiceImpl implements IUserInfoEsService {

    @Autowired
    private UserInfoEsRepository userInfoEsRepository;

    @Override
    public void save(UserInfoEs UserInfoEs) {
        userInfoEsRepository.save(UserInfoEs);
    }

    @Override
    public void update(UserInfoEs UserInfoEs) {
        userInfoEsRepository.save(UserInfoEs);
    }

    @Override
    public void dilete(String id) {
        userInfoEsRepository.deleteById(id);
    }

    @Override
    public UserInfoEs get(String id) {
        return userInfoEsRepository.findById(id).orElse(null);
    }

    @Override
    public List<UserInfoEs> list() {
        ArrayList<UserInfoEs> list = new ArrayList<>();
        Iterable<UserInfoEs> all = userInfoEsRepository.findAll();
        all.forEach(item -> list.add(item));
        return list;
    }
}
